#ifndef REGISTERDIALOG_H
#define REGISTERDIALOG_H

#include <QWidget>
#include <QDialog>
#include <QComboBox>
#include <QLabel>
#include <QHBoxLayout>
#include <tcpclient.h>

namespace Ui {
class RegisterDialog;
}

class RegisterDialog : public QDialog
{
    Q_OBJECT

public:
    explicit RegisterDialog(QWidget *parent = nullptr);
    ~RegisterDialog();

    void handleResults(const bool& results);
    void handleError(const QString& errorMessage);
private:
    Ui::RegisterDialog *ui;
    QPushButton* buttot_1;
    QPushButton* buttot_2;
    QComboBox *comboBox;
    QLabel* roleLabel;
    QHBoxLayout* roleLayout;
    QHBoxLayout* buttonLayout;
    QString role;
    QString username;
    QString password;
    void createButton();
    void createTextInput();
    void createCombox();
    bool isValidIDNumber(const QString& username);
    bool isValidPassword(const QString& password);
    TcpClient* m_client;
public slots:
    /**
     * @brief 初始化界面
     */
    void initializeInterface();
    void RegisterUser();
signals:
    void createTCP();
};

#endif // REGISTERDIALOG_H
